Xbasic

CAN_DATABASE_EXIT Function

Syntax

C can_database_exit(C code )

Arguments

code

A character string containing lines of Xbasic to be executed.

Description

Registers code to be executed before the current database is closed. If Cancel() is called, the database is not closed.

Discussion

The CAN_DATABASE_EXIT() function allows you to "register" code that will be executed when the current database is about to be closed. You can call the function as many times as you want to register as many different code snippets as you want. the code that is executed must issue a CANCEL()command in order to prevent the database from closing. To delete any code that was previously registered, but is no longer wanted, use the SYSTEM_EVENT_DROP("database_exit", name) command, where name is the sub-property of the p.database_exit variable returned by a call to the SYSTEM_EVENT_DATA_GET()function

Example

dim code as C
dim ret as N
code = 
ret = ui_msg_box("Notice", "Are you sure you want to exit?",UI_YES_NO)
if (ret = UI_NO_SELECTED) then
    CANCEL()
end if
%code%
can_database_exit(code)

See Also